package com.example.emojibase;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class EmojiBaseDB extends SQLiteOpenHelper{
    private static final int VERSION=1;
    private static final String DBNAME="EmojiBaseDB.db";
    private static EmojiBaseDB sInstance;

    private EmojiBaseDB(Context context) {
        super(context, DBNAME, null, VERSION);
    }

    //创建数据库
    public void onCreate(SQLiteDatabase db){
        db.execSQL("create table emoji(emoji_id integer primary key autoincrement, name text, avatar BLOB)");
    }
    //数据库版本更新
    public void onUpgrade(SQLiteDatabase db,int oldVersion,int newVersion) {
    }

    public static synchronized EmojiBaseDB getInstance(Context context) {
        if (sInstance == null) {
            sInstance = new EmojiBaseDB(context.getApplicationContext());
        }
        return sInstance;
    }

}
